<%@ page language="java" import="com.ruohi.util.common.CommonForm,com.ruohi.util.common.Env" pageEncoding="UTF-8" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.TreeMap" %>
<%
	String tableName = "view_gift_product_advanced";
	String tablePrefix = Env.getInstance().getProperty("table_prefix");
	String fileds = "id,add_date,uuid,product_no,product_name,mem_no,nick_name,mem_name,type,tel,mobile,email,advanced_count,status";
	String whereStr = " ";
	String orderByStr = " id desc ";
	
	Map statusMap = new TreeMap();
	statusMap.put("", "-请选择-");
	statusMap.put("1", "未处理");
	statusMap.put("2", "已处理");
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><%=Env.getInstance().getProperty("project_name") %></title>
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
  </head>
  <body>
  	<div class="searchForm">
  		<div class="searchCondition">
  			<div class="searchList" style="width:440px;">
		  		<div class="searchLeft">预定日期</div>
		  		<div class="searchRight" style="width:320px;">
		  			<input type="text" class="Wdate jr_text" style="width:120px;" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="add_date_start" id="add_date_start" />
		  			-
		  			<input type="text" class="Wdate jr_text" style="width:120px;" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="add_date_end" id="add_date_end" />
		  		</div>
		  	</div>
            <div class="searchList">
		  		<div class="searchLeft">会员号</div>
		  		<div class="searchRight">
		  			<input type="text" class="jr_text" name="mem_no" id="mem_no" />
		  		</div>
		  	</div>
		  	<div class="searchList">
		  		<div class="searchLeft">真实姓名</div>
		  		<div class="searchRight">
		  			<input type="text" class="jr_text" name="mem_name" id="mem_name" />
		  		</div>
		  	</div>
		  	<div class="searchList">
		  		<div class="searchLeft">处理状态</div>
		  		<div class="searchRight">
		  			<select name="status" id="status" class="jr_select">
		  				<%=CommonForm.createSelect(statusMap, "") %>
		  			</select>
		  		</div>
		  	</div>
  		</div>
  		<div class="searchBtn">
  			<input type="button" class="btn" onclick="doSearch();" value="查询" /><input type="button" style="margin-left: 5px;" class="btn" onclick="doClearForm();" value="重置" />
  		</div>
  	</div>
  	<div style="clear: left;"></div>
  	
	<div class="l-loading" style="display: block" id="pageloading"></div> 
	<div id="maingrid" style="margin: 0; padding: 0"></div>
	<div style="display: none;"></div>
  </body>
</html>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/plugin/date/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js" prefix="<%=tablePrefix %>" type="text/javascript"></script>
<script type="text/javascript">
	var grid;
	var windowWidth = 700;
	var windowHeight = 240;
	var tableName = "<%=tableName %>";
	var fields = "<%=fileds %>";
	var whereStr = "<%=whereStr %>";
	var orderBy = "<%=orderByStr %>";
	var columnsArr = [];
	var url = "";
	var conditionStr = "";
	var params = [];
	jQuery(function() {
		params.push({'name':'enumNo','value':'106013'});
		grid = new Dev21sunGrid();
		jQuery("#pageloading").hide();
	});
	var is_showData = [{ is_show : 1 , text: '是' }, { is_show : 0 , text: '否'}];
	//列数组
	columnsArr =  [
		{ display:"预定日期", name:"add_date", align:"center", type:"date", width:100 },
		{ display : '预定产品', name : 'product_name', align : 'left' , type : 'string' , width : 200, render:function(row){
            return "<a target='_blank' href='http://www.52sdskj.com/product/" + row.product_no + ".htm'><img class='preview' src='/plugin/ui/ligerUI/ligerUI/skins/icons/preview.png' /></a>" + row.product_name;
		} }  ,
		{ display : '预定数量', name:"advanced_count", align : 'center' , type : 'int' , width : 80 } ,
		{ display:"预定人会员号/昵称/真实姓名", align:"center", type:"string", width:200, render:function(row){
			return row.mem_no + "/" + row.nick_name + "/" + row.mem_name;
		} },
		{ display:"座机", name:"tel", align:"center", type:"string", width:100 },
		{ display:"手机", name:"mobile", align:"center", type:"string", width:120 },
		{ display:"邮箱", name:"email", align:"center", type:"string", width:150 },
		{ display:"处理状态", name:"status", align:"center", type:"int", width:130, render:function(row){
			return row.status > 1 ? "<font color='green'>已处理</font>" : "<font color='red'>未处理</font>&nbsp;&nbsp;<a href='javascript://void(0);' onclick='updateStatus(\"" + row.uuid + "\" ,2);'>标记为已处理</a>";
		} }
	];
	
	/*列表页条件查询*/
	function doSearch(){
		params = [];
		conditionStr = "";
		var start_date = jQuery("#add_date_start").val();
		if(''!=jQuery.trim(start_date)){
			conditionStr += " and add_date > '"+start_date+"' ";
		}
		var end_date = jQuery("#add_date_end").val() ;
		if(''!=jQuery.trim(end_date)){
		    conditionStr += " and add_date < '"+end_date+"'" ;
		}
		var mem_no = jQuery("#mem_no").val();
		if(''!=jQuery.trim(mem_no)){
			conditionStr += " and mem_no like '%"+mem_no+"%' ";
		}
		var mem_name = jQuery("#mem_name").val();
		if(''!=jQuery.trim(mem_name)){
			conditionStr += " and mem_name like '%"+mem_name+"%' ";
		}
		var status = jQuery("#status").val();
		if(''!=jQuery.trim(status)){
			conditionStr += " and status = " + status;
		}
		params.push({'name':'enumNo','value':'106013'});
		params.push({'name':'tableName','value':tableName});
		params.push({'name':'fields','value':fields});
		params.push({'name':'whereStr','value':whereStr+conditionStr});
		params.push({'name':'orderBy','value':orderBy});
		grid.options.parms=params;
		grid.loadData();
	}
	
	function addAndEdit(index){
		if(undefined==index){//如果是增加
			toolbarAdd({
				width:600,
				height:400,
				title:"增加"
			});
		}else{//如果是修改
	    	var row = grid.getRow(index);
	    	toolbarAdd({width:600,height:400,title:'编辑'},row.uuid);
		}
    }
    
    function updateStatus(uuid, status){
    	$.ajax({
    		type:"post",
    		url:"/backend/action/ajax_r.jsp",
    		data:{flag:"updateAdvancedStatus", uuid:uuid, status:status, enumNo:"106013"},
    		success:function(result){
    			grid.loadData();
    		}
    	});
    }
</script>